@import (once) "../../include/vars";
@import (once) "../../include/mixins";

:root {
    --window-scrollbar-size: 6px;
    --window-scrollbar-track-radius: 0;
    --window-border-size: 4px;
    --window-border-radius: 6px;
    --window-border-color: #f3f3f3;
    --window-background: #fff;
    --window-color: #191919;
    --window-button-size: 24px;
    //--window-caption-background: #f3f3f3;
    --window-caption-color: #191919;
    --window-scrollbar-thumb-color: #a8a8a8;
    --window-scrollbar-track-color: #f1f1f1;
    --window-resize-element-color: #a8a8a8;
    --window-sys-button-color: #191919;
    --window-sys-button-backgroud-hover: #d8d8d8;
    --window-close-button-backgroud-hover: #C75050FF;
    --window-close-button-color-hover: #ffffff;
}

.dark-side {
    --window-border-color: #484b4c;
    --window-background: #1e1f22;
    --window-color: #dbdfe7;
    //--window-caption-background: #484b4c;
    --window-caption-color: #dbdfe7;
    --window-scrollbar-thumb-color: #d1d1d1;
    --window-scrollbar-track-color: #2c2c2c;
    --window-resize-element-color: #2c2c2c;
    --window-sys-button-color: #ffffff;
    --window-sys-button-backgroud-hover: #2c2c2c;
    --window-close-button-backgroud-hover: #C75050FF;
    --window-close-button-color-hover: #ffffff;
}

.window {
    display: flex;
    flex-direction: column;
    position: relative;
    height: auto;
    background-color: var(--window-background);
    color: var(--window-color);
    border: 1px var(--window-border-color) solid;
    z-index: 1;
    border-radius: var(--window-border-radius);
    overflow: hidden;
    
    &.shadowed {
        box-shadow: rgba(0, 0, 0, 0.24) 0 3px 8px;
    }
}

.window-caption {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    height: 2.25rem;
    line-height: 2.25rem;
    padding: 0;
    border-bottom: 1px transparent solid;
    cursor: default;
    vertical-align: middle;
    background-color: var(--window-border-color);
    color: var(--window-caption-color);
    user-select: none;
}

.window-caption {
    .title {
        font-size: .875rem;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        width: 100%;
        padding-left: 4px;
        color: inherit;
    }

    .icon {
        width: 34px;
        height: 34px;
        text-align: center;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        color: inherit;

        * {
            width: 1rem;
            font-size: 1rem;
            line-height: 34px;
            text-align: center;
        }
    }

    * + .title {
        padding-left: 0;
    }
}

.window-caption {
    .buttons {
        height: var(--window-button-size);
        margin-left: auto;
        display: flex;
        flex-wrap: nowrap;
        flex-direction: row;
        margin-right: 4px;
        gap: 2px
    }

    .btn-custom {
        &:focus, &:active {
            box-shadow: none!important;
        }
    }

    .buttons {
        .sys-button {
            background-color: transparent;
            color: var(--window-sys-button-color);
            border-radius: 0;
            border: none;
            &:hover {
                background-color: var(--window-sys-button-backgroud-hover);
            }
            &:active {
                background-color: var(--window-sys-button-backgroud-hover);
            }
        }

        .btn-min, .btn-max, .btn-close {
            height: var(--window-button-size)!important;
            width: var(--window-button-size)!important;
            padding: 0!important;

            &::before {
                display: block;
                position: absolute;
                content: '';
            }
        }

        .btn-min {
            &::before {
                content: "🗕";
            }
        }
        
        .btn-max {
            &::before {
                content: "🗖";
            }
        }

        .btn-close {
            &::before {
                content: "✕";
            }
        }
        
        .btn-custom {
            min-width: 34px;
            width: auto;
            flex-shrink: 0;
            height: var(--window-button-size)!important;
        }

        .btn-close {
            &:hover {
                background-color: var(--window-close-button-backgroud-hover);
                color: var(--window-close-button-color-hover);
                &::before {
                    color: var(--window-close-button-color-hover);
                }
            }
            &:active {
                background-color: var(--window-close-button-backgroud-hover);
                color: var(--window-close-button-color-hover);
            }
        }

        .btn-custom {order: 1;}
        .btn-min {order: 2;}
        .btn-max {order: 3;}
        .btn-close {order: 4;}
    }
}

.window-content {
    overflow: auto;
    height: calc(100% - 2.25rem);
    border: var(--window-border-size) var(--window-border-color) solid;
    background-color: transparent;
    padding: calc(var(--window-border-size) * 2);
    font-size: 14px;
    
    & > * {
        height: 100%;
    }
    
    &::-webkit-scrollbar {
        height: var(--window-scrollbar-size);
        width: var(--window-scrollbar-size);
    }

    &::-webkit-scrollbar-track {
        border-radius: var(--window-scrollbar-track-radius);
        background-color: var(--window-scrollbar-track-color);
    }
    
    &::-webkit-scrollbar-thumb {
        background: var(--window-scrollbar-thumb-color);
        border-radius: 10px;
    }
}

.window-status {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    background-color: var(--window-border-color);
    color: var(--window-color);
    height: 18px;
    font-size: 12px;
    align-items: center;
    padding: 0 .5rem .25rem;
}

.window {
    &.info-window {
        --window-border-color: @infoColor;
        --window-caption-background: @infoColor;
        --window-caption-color: @white;
        --window-sys-button-color: @white;
    }
    &.alert-window {
        --window-border-color: @alertColor;
        --window-caption-background: @alertColor;
        --window-caption-color: @white;
        --window-sys-button-color: @white;
    }
    &.warning-window {
        --window-border-color: @warningColor;
        --window-caption-background: @warningColor;
        --window-caption-color: @white;
        --window-sys-button-color: @white;
    }
    &.success-window {
        --window-border-color: @successColor;
        --window-caption-color: @white;
        --window-sys-button-color: @white;
    }
}

.window {
    &.focused {
        box-shadow: 0 25px 50px -12px var(--shadow-color-large-extra);
    }
}

.window {
    &.modal {
        z-index: @zindex-modal;
    }
}

.window {
    &.minimized {
        max-width: 12rem;
        max-height: 2.25rem;

        .window-caption {
            border-bottom: none!important;
        }

        .window-content {
            display: none!important;
        }

        .window-caption .btn-custom {
            display: none;
        }
    }

    &.maximized {
        top: 0!important;
        left: 0!important;
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        max-width: none !important;
        border-radius: 0!important;

        .btn-max {
            &::before {
                content: "🗗";
            }
        }
    }

    &.resizable {
        min-width: 12rem;
        min-height: 2.25rem;
    }
    
    .resize-element {
        bottom: 2px;
        right: 2px;
        &::after {
            border-bottom-color: var(--window-resize-element-color);
        }
    }
}

